<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN"
          "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>Backgound HTML of Mobile Locating Extension</title>
    </head>
    <body>
        <script type="text/javascript" src="utils.js"></script>
        <script type="text/javascript">
            function mobile_locating(mobile, callback){
                var xhr = new XMLHttpRequest();
                xhr.onreadystatechange = function(data){
                    if(xhr.readyState != 4) return ;
                    if(xhr.status == 200){
                        try{
                            var data = eval('(' + xhr.responseText + ')');
                        }catch(e){
                            Utils.log('Parsing JSON data error:' + e);
                            return;
                        }
                        callback(data);
                    }
                }
                xhr.open("POST", "http://api.showji.com/locating/?m=" + encodeURIComponent(mobile) + "&output=json", true);
                xhr.send();
            }
            function onRequest(req, sender, callback){
                mobile_locating(req.mobile, callback);
            }
            chrome.extension.onRequest.addListener(onRequest);
        </script>
    </body>
</html>
